
#include <QObject>
#include <QIcon>
#include <QTextCodec>

#include <QDesktopWidget>
#include <QLocale>
#include <QTranslator>

#include "CONST.h"
#include "auxiliaries_func.h"
//-----------------------------------------------------------------
void setCodecForApplication(const char *codec_name){
//    QTextCodec *codec = QTextCodec::codecForName(codec_name);//"CP1251" //"UTF-8"
//    QTextCodec::setCodecForTr(codec);
//    QTextCodec::setCodecForCStrings(codec);
}

//-----------------------------------------------------------------
void setWindowCenter(QWidget *fm) {
    QRect rect_geometry = fm->geometry();
    rect_geometry.moveCenter(QApplication::desktop()->availableGeometry().center());
    fm->setGeometry(rect_geometry);
}

//-----------------------------------------------------------------
void setIconToWin(const char* iconPath, QWidget *fm) {
    QIcon icon;
    icon.addFile(QString::fromUtf8(iconPath), QSize(), QIcon::Normal, QIcon::Off);
    fm->setWindowIcon(icon);
}

//-----------------------------------------------------------------
/*
//variant:
void MainWindow::centerOnDesktop(){
    quint16 screenWidth, width, screenHeight, height, x, y;
    QSize windowSize;

    screenWidth = QApplication::desktop()->width();
    screenHeight = QApplication::desktop()->height();
    windowSize = size();
    width = windowSize.width();
    height = windowSize.height();
    x = (screenWidth - width) / 2;
    y = (screenHeight - height) / 2;
    y -= 100;
    move(x, y);
}
*/



//-----------------------------------------------------------------
/*
Qt::Window
| Qt::MSWindowsFixedSizeDialogHint
| Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
*/

void setWindowFixedCloseOnlyStayOnTop(QWidget *fm) {
    fm->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint |
                       Qt::WindowSystemMenuHint |
                       Qt::WindowStaysOnTopHint);
}

void setWindowFixed(QWidget *fm) {
    fm->setWindowFlags(Qt::WindowSystemMenuHint);
}

void setWindowStayOnTop(QWidget *fm) {
    fm->setWindowFlags(Qt::WindowStaysOnTopHint);
}


void setWindowMaximized(QWidget *fm) {
    fm->setWindowState(Qt::WindowMaximized);
}

//----------------------------------------------------------------------------------------
//void setLocaleForApplication(QTranslator &tr) {
//    QString locale = QLocale::system().name();
////    QString locale = locale_ru;
////    if(tr.load(QString("translate_ru")))
//    if(tr.load(translationDir + "/" + QString(fileTranslator) + locale))
//        qDebug() << "translate loaded ok";
//    else
//        qDebug() << "translate file not found";

//}
